<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/resources/css/back/command.css">

</head>
<body>
	<button class="btn btn-primary" data-toggle="modal" data-target="#parent">添加父条目</button>
	<br><br>
	<div class="table-responsive">
	<table class="table table-striped table-hover table-bordered ">
		<thead>
			<tr class="info">
				<td>编号</td>
				<td>指令</td>
				<td>操作</td>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${CommandList }" var="Command">
			<tr>
				<td class='id'>${Command.id }</td>
				<td><input type="text" class="command" value=" ${Command.command }"></td>
				<td><button class="btn btn-success" onclick='save(this)'>保存修改</button>&nbsp;&nbsp;<button class="btn btn-info" onclick="showRight('<%=request.getContextPath() %>/commanddetail','${Command.id }')">查看子条目</button>&nbsp;&nbsp;
				<button class="btn btn-primary" data-toggle="modal" data-target="#child" onclick="getcommandId(this)">添加子条目</button>&nbsp;&nbsp;<button class="btn btn-danger" onclick="deletecommand(${Command.id })">删除</button></td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
	</div>
	<span class="col-md-7 col-sm-4"></span>
		 <ul class="pager col-md-5 col-sm-8">
			 <li>共${page.pages }页，当前第${page.pageNum }页</li>
			 <li><a href="JavaScript:void()" onclick="showRight('<%=request.getContextPath() %>/commandlist','id','${page.firstPage}')">首页</a></li>
			 <li><a href="JavaScript:void()" onclick="showRight('<%=request.getContextPath() %>/commandlist','id','${page.prePage}')">上一页</a></li>
			 <li><a href="JavaScript:void()" onclick="showRight('<%=request.getContextPath() %>/commandlist','id','${page.nextPage}')">下一页</a></li>
			 <li><a href="JavaScript:void()" onclick="showRight('<%=request.getContextPath() %>/commandlist','id','${page.lastPage}')">尾页</a></li>
		 </ul>
	 
	 <!-- 添加子条目弹窗 -->
<div class="modal fade" id="child">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" ><span>&times;</span></button>
	        <h3 class="modal-title">添加子条目</h3>
	      </div>
	      <div class="modal-body">
	        	<div class="input-group">
	        		 <span class="input-group-addon">父条目ID:</span>
	        		<span class="form-control" id="commandId"></span>
	        	</div>
	        	<br>
	        	<div class="input-group">
	        		 <span class="input-group-addon">指令:</span>
	        		<input type="text" class="form-control" name="description" placeholder="请输入指令">
	        	</div>
	        	<br>
	        	<div class="input-group">
	        		 <span class="input-group-addon">内容:</span>
	        		<input type="text" class="form-control" name="content" placeholder="请输入内容">
	        	</div>
	      </div>
	      <div class="modal-footer">
	      	<button type="button" class="btn btn-primary" onclick="save_child()">提交</button>
	        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	      </div>
	    </div>
	  </div>
</div>
	 
	 	 <!-- 添加父条目弹窗 -->
<div class="modal fade" id="parent">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" ><span>&times;</span></button>
	        <h3 class="modal-title">添加父条目</h3>
	      </div>
	      <div class="modal-body">
	        	<div class="input-group">
	        		 <span class="input-group-addon">指令:</span>
	        		<input type="text" class="form-control" name="command" placeholder="请输入指令">
	        	</div>
	      </div>
	      <div class="modal-footer">
	      	<button type="button" class="btn btn-primary" onclick="save_parent()">提交</button>
	        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	      </div>
	    </div>
	  </div>
</div>
	 
	 <script type="text/javascript" src="<%=request.getContextPath() %>/resources/js/back/command.js"></script>
	 
</body>
</html>